
#include"server.hpp"

void Json_test()
{

    Json::Value stu;

    stu["name"] = "xiao wang";
    stu["id"] = "123456";
    stu["score"].append(77);
    stu["score"].append(88.5);
    stu["score"].append(90);

    std::string str;

    ns_util::json_util::json_serialize(stu, &str);

    std::cout << str << std::endl;


}

void FileRead_test()
{
    std::string str;

    ns_util::file_util::read("makefile", &str);

    std::cout << str << std::endl;
}


//测试数据管理模块
void Data_test()
{

    //可以只输入密码和选择数据库
    user_table user("127.0.0.1","root","13623964732","online_gobang");

    Json::Value stu;
    stu["username"]="小王";
    stu["password"]="123456";

    //user.insert(stu);

    user.select_by_name("小王",stu);


    std::string str;
    ns_util::json_util::json_serialize(stu,&str);

    std::cout<<str<<std::endl;

    // user.win(stu["id"].asInt());
    // user.win(stu["id"].asInt());
}

void online_test()
{
    online_manager ms;
    websocket_server::connection_ptr conn;
    uint64_t id=2;

    ms.enter_game_hall(id,conn);
    if(ms.is_in_game_hall(id))
    {
        std::cout<<"is in the hall"<<std::endl;
    }
    else{
        std::cout<<"not int the hall"<<std::endl;
    }

    if(ms.is_in_game_room(id))
    {
        std::cout<<"is in the room"<<std::endl;
    }
    else{
        std::cout<<"not in the room"<<std::endl;
    }


}

void server_test()
{
    gobang_server server("127.0.0.1","root","13623964732","online_gobang");
    server.start(15535);
}



int main()
{

    server_test();
    

    return 0;
}